<?php
/**
* redis 链接类
*/
class QueueHelper
{
    public static $redis;

    public static $instance;

    public static function getRedis()
    {
        if (!isset(self::$redis) || is_null(self::$redis)) {
            self::$instance = new QueueHelper();
            self::$redis = new Redis();
            self::$redis->connect('127.0.0.1', 6379);
        }
        return self::$instance;
    }

    public function set($key, $value, $expire=0)
    {
        self::$redis->setex($key, $value, $expire);
    }

    public function get($key)
    {
        return self::$redis->get($key);
    }

    public function setSet($key, $value)
    {
        var_dump(self::$redis);
        $status = self::$redis->sAdd($key, $value);
        var_dump($status);
    }

    public function sGet($key)
    {
        return self::$redis->sMembers($key);
    }

}
